(function() {
  var LRU, g_lru;

  LRU = require("lru-cache");

  g_lru = [];

  exports.common_lrucache = {
    load: function(id, cb) {
      var cache, timeout, v, _i, _len, _ref;

      for (_i = 0, _len = g_lru.length; _i < _len; _i++) {
        _ref = g_lru[_i], timeout = _ref[0], cache = _ref[1];
        v = cache.get(id);
        if (v) {
          return cb(null, v);
        }
      }
      return cb(null, null);
    },
    save: function(id, val, timeout, cb) {
      var c, cache, timeout2, _i, _len, _ref;

      if (timeout < 10) {
        return cb(null, val);
      }
      c = null;
      for (_i = 0, _len = g_lru.length; _i < _len; _i++) {
        _ref = g_lru[_i], timeout2 = _ref[0], cache = _ref[1];
        if (timeout === timeout2) {
          c = cache;
          break;
        }
      }
      if (c === null) {
        c = LRU({
          max: 100,
          maxAge: timeout * 1000
        });
        g_lru.push([timeout, c]);
      }
      c.set(id, val);
      return cb(null, val);
    }
  };

}).call(this);